from selenium.webdriver.common.by import By

from common.Utils import ForumDriver
#论坛首页测试用例
class ForumList:
    url = ""
    driver = ""
    def __init__(self):
        self.url = "http://127.0.0.1:9580/index.html"
        self.driver = ForumDriver.driver
        self.driver.get(self.url)
    #测试首页(登录情况下）
    def ListTestByLogin(self):
        #测试帖子分类
        self.driver.find_element(By.CSS_SELECTOR, "#topBoardList > li:nth-child(2) > a > span.nav-link-title").click()
        # 添加屏幕截图
        ForumDriver.getScreeShot()
        #测试帖子标题是否存在
        self.driver.find_element(By.CSS_SELECTOR,"#artical-items-body > div:nth-child(1) > div > div.col > div.text-truncate > a > strong")
        #测试帖子详情是否存在
        self.driver.find_element(By.CSS_SELECTOR,"#artical-items-body > div:nth-child(1) > div > div.col > div.text-truncate > a > strong")
        #测试时间是否存在
        self.driver.find_element(By.CSS_SELECTOR,"#artical-items-body > div:nth-child(1) > div > div.col > div.text-muted.mt-2 > div > div.col > ul > li:nth-child(2)")
        #测试切换夜间模式
        self.driver.find_element(By.CSS_SELECTOR,"body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > div > div:nth-child(2) > a.nav-link.px-0.hide-theme-dark > svg")
        #测试查看站内消息是否存在
        self.driver.find_element(By.CSS_SELECTOR,"body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > div > div:nth-child(2) > div > a > svg")
        #测试发布帖子是否存在
        self.driver.find_element(By.CSS_SELECTOR,"#bit-forum-content > div.page-header.d-print-none > div > div > div.col-auto.ms-auto.d-print-none > div > a.btn.btn-primary.d-none.d-sm-inline-block.article_post")
        #测试搜索框是否存在
        self.driver.find_element(By.CSS_SELECTOR,"body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > div > div.nav-item.d-none.d-md-flex.me-3 > div > form > div > input")
        #个人信息-检查昵称是否存在
        self.driver.find_element(By.CSS_SELECTOR,"#index_nav_nickname")
        #头像是否存在
        self.driver.find_element(By.CSS_SELECTOR,"#index_nav_avatar")

